libname dd 'D:\local_c\bfeed3';

**basic maternal characteristics for REStat, "Breastfeeding and Children's Early Cognitive Outcomes";
**note, will do marital status at birth and employment separately;

data x;
infile 'D:\local_c\bfeed3\mom08.dat' lrecl=393 missover DSD DLM=' ';
input
  R0000100
  R0000700
  R0010400
  R0173600
  R0214700
  R0214800
  R0216400
  R0216701
  R0217900
  R0217910
  R0405700
  R0406010
  R0406100
  R0406401
  R0602810
  R0618410
  R0618500
  R0618901
  R0897910
  R0898201
  R0898600
  R0898700
  R1144500
  R1144600
  R1144800
  R1145001
  R1519700
  R1519800
  R1520000
  R1520201
  R1890400
  R1890500
  R1890700
  R1890901
  R2257500
  R2257600
  R2257800
  R2258001
  R2444700
  R2444800
  R2444900
  R2445200
  R2445401
  R2870200
  R2870400
  R2870800
  R2871101
  R3074000
  R3074100
  R3074500
  R3074801
  R3400700
  R3400800
  R3401200
  R3401501
  R3656100
  R3656200
  R3656600
  R3656901
  R4006600
  R4006700
  R4007100
  R4007401
  R4417700
  R4417800
  R4418200
  R4418501
  R5080700
  R5080800
  R5081200
  R5103900
  R5166000
  R5166100
  R5166500
  R5166901
  R6478700
  R6478800
  R6479100
  R6479600
  R7006500
  R7006600
  R7006800
  R7007300
  R7703700
  R7703900
  R7704100
  R7704600
  R8496100
  R8496300
  R8496500
  R8497000
  T0987800
  T0987900
  T0988300
  T0988800
  T2210000
  T2210100
  T2210300
  T2210700
;

  label R0000100 = "ID# (1-12686) 79";
  label R0000700 = "CNTRY OF BIRTH 79";
  label R0010400 = "PRSNT RELGS AFFILIATION 79";
  label R0173600 = "SAMPLE ID  79 INT";
  label R0214700 = "RACL/ETHNIC COHORT /SCRNR 79";
  label R0214800 = "SEX OF R 79";
  label R0216400 = "REGION OF CURRENT RESIDENCE 79";
  label R0216701 = "HIGHEST GRADE COMPLTD (REV) 79";
  label R0217900 = "TOT NET FAMILY INC P-C YR 79";
  label R0217910 = "FAMILY POV STATUS IN 78 79";
  label R0405700 = "REGION OF CURRENT RESIDENCE 80";
  label R0406010 = "TOT NET FAMILY INC P-C YR 80";
  label R0406100 = "FAMILY POV STATUS IN 79 80";
  label R0406401 = "HIGHEST GRADE COMPLTD (REV) 80";
  label R0602810 = "REGION OF CURRENT RESIDENCE 81";
  label R0618410 = "TOT NET FAMILY INC P-C YR 81";
  label R0618500 = "FAMILY POV STATUS IN 80 81";
  label R0618901 = "HIGHEST GRADE COMPLTD (REV) 81";
  label R0897910 = "REGION OF CURRENT RESIDENCE 82";
  label R0898201 = "HIGHEST GRADE COMPLTD (REV) 82";
  label R0898600 = "TOT NET FAMILY INC P-C YR 82";
  label R0898700 = "FAMILY POV STATUS IN 81 82";
  label R1144500 = "TOT NET FAMILY INC P-C YR 83";
  label R1144600 = "FAMILY POV STATUS IN 82 83";
  label R1144800 = "REGION OF CURRENT RESIDENCE 83";
  label R1145001 = "HIGHEST GRADE COMPLTD (REV) 83";
  label R1519700 = "TOT NET FAMILY INC P-C YR 84";
  label R1519800 = "FAMILY POV STATUS IN 83 84";
  label R1520000 = "REGION OF CURRENT RESIDENCE 84";
  label R1520201 = "HIGHEST GRADE COMPLTD (REV) 84";
  label R1890400 = "TOT NET FAMILY INC P-C YR 85";
  label R1890500 = "FAMILY POV STATUS IN 84 85";
  label R1890700 = "REGION OF CURRENT RESIDENCE 85";
  label R1890901 = "HIGHEST GRADE COMPLTD (REV) 85";
  label R2257500 = "TOT NET FAMILY INC P-C YR 86";
  label R2257600 = "FAMILY POV STATUS IN 85 86";
  label R2257800 = "REGION OF CURRENT RESIDENCE 86";
  label R2258001 = "HIGHEST GRADE COMPLTD (REV) 86";
  label R2444700 = "TOT NET FAMILY INC P-C YR 87";
  label R2444800 = "TOT NET FAMILY INC P-C YR CENSUS 87";
  label R2444900 = "FAMILY POV STATUS IN 86 87";
  label R2445200 = "REGION OF CURRENT RESIDENCE 87";
  label R2445401 = "HIGHEST GRADE COMPLTD (REV) 87";
  label R2870200 = "TOT NET FAMILY INC P-C YR 88";
  label R2870400 = "FAMILY POV STATUS IN 87 88";
  label R2870800 = "REGION OF CURRENT RESIDENCE 88";
  label R2871101 = "HIGHEST GRADE COMPLTD (REV) 88";
  label R3074000 = "TOT NET FAMILY INC P-C YR 89";
  label R3074100 = "FAMILY POV STATUS IN 88 89";
  label R3074500 = "REGION OF CURRENT RESIDENCE 89";
  label R3074801 = "HIGHEST GRADE COMPLTD (REV) 89";
  label R3400700 = "TOT NET FAMILY INC P-C YR 90";
  label R3400800 = "FAMILY POV STATUS IN 89 90";
  label R3401200 = "REGION OF CURRENT RESIDENCE 90";
  label R3401501 = "HIGHEST GRADE COMPLTD (REV) 90";
  label R3656100 = "TOT NET FAMILY INC P-C YR 91";
  label R3656200 = "FAMILY POV STATUS IN 90 91";
  label R3656600 = "REGION OF CURRENT RESIDENCE 91";
  label R3656901 = "HIGHEST GRADE COMPLTD (REV) 91";
  label R4006600 = "TOT NET FAMILY INC P-C YR 92";
  label R4006700 = "FAMILY POV STATUS IN 91 92";
  label R4007100 = "REGION OF CURRENT RESIDENCE 92";
  label R4007401 = "HIGHEST GRADE COMPLTD (REV) 92";
  label R4417700 = "TOTAL NET FAMILY INCOME 93";
  label R4417800 = "POVERTY STATUS 93";
  label R4418200 = "REGION OF RESIDENCE 93";
  label R4418501 = "HIGHEST GRADE COMPLTD (REV) 93";
  label R5080700 = "TOTAL NET FAMILY INCOME 94";
  label R5080800 = "POVERTY STATUS 94";
  label R5081200 = "REGION OF RESIDENCE 94";
  label R5103900 = "HIGHEST GRADE COMPLTD (REV) 94";
  label R5166000 = "TOTAL NET FAMILY INCOME 96";
  label R5166100 = "POVERTY STATUS IN 1995 96";
  label R5166500 = "REGION OF RESIDENCE 96";
  label R5166901 = "HIGHEST GRADE COMPLTD (REV) 96";
  label R6478700 = "TOTAL NET FAMILY INCOME 1998";
  label R6478800 = "POVERTY STATUS 1998";
  label R6479100 = "REGION OF RESIDENCE 1998";
  label R6479600 = "HIGHEST GRADE COMPLTD (REV) 1998";
  label R7006500 = "TOTAL NET FAMILY INCOME 2000";
  label R7006600 = "POVERTY STATUS 2000";
  label R7006800 = "REGION OF RESIDENCE 2000";
  label R7007300 = "HIGHEST GRADE COMPLTD (REV) 2000";
  label R7703700 = "TOTAL NET FAMILY INCOME 2002";
  label R7703900 = "POVERTY STATUS 2002";
  label R7704100 = "REGION OF RESIDENCE 2002";
  label R7704600 = "HIGHEST GRADE COMPLTD (REV) 2002";
  label R8496100 = "TOTAL NET FAMILY INCOME 2004";
  label R8496300 = "POVERTY STATUS 2004";
  label R8496500 = "REGION OF RESIDENCE 2004";
  label R8497000 = "HIGHEST GRADE COMPLTD (REV) 2004";
  label T0987800 = "TOTAL NET FAMILY INCOME 2006";
  label T0987900 = "POVERTY STATUS 2006";
  label T0988300 = "REGION OF RESIDENCE 2006";
  label T0988800 = "HIGHEST GRADE COMPLTD (REV) 2006";
  label T2210000 = "TOTAL NET FAMILY INCOME 2008";
  label T2210100 = "POVERTY STATUS 2008";
  label T2210300 = "REGION OF RESIDENCE 2008";
  label T2210700 = "HIGHEST GRADE COMPLTD (REV) 2008";

proc sort;  by r0000100;  run;

data y;
set dd.child08;
keep r0000100 c0000100 cyob year56 c0000200;

r0000100 = c0000200;

proc sort;  by r0000100;

data z;
merge x y;  by r0000100;

if c0000100 ne .;


data dd.mom08;
set z;
keep r0000100 c0000100 c0000200 momfor r0173600 bapt79 cath79 region inc56 pov56 hgcyob
reg79 hgc79;

*foreign born;
momfor = .;
if r0000700 = 1 then momfor = 0 ;
if r0000700 = 2 then momfor = 1;

*religion;
bapt79 = .;
if (r0010400 = 2) then bapt79 = 1;
if (r0010400 = 0 or r0010400 = 1 or r0010400 ge 3) then bapt79 = 0;

cath79 = .;
if (r0010400 = 7) then cath79 = 1;
if (r0010400 ge 0 and r0010400 le 6) then cath79 = 0;
if (r0010400 gt 7) then cath79 = 0;

**since will only be missing a few here, will hand code based on religion raised in;
**r0010300;
if (r0000100 = 1103 or r0000100 = 2646 or r0000100 = 5801) then do;
cath79 = 1;
bapt79 = 0;
end;
if (r0000100 = 5753 or r0000100 = 5951 or r0000100 = 8289) then do;
cath79 = 0;
bapt79 = 1;
end;
if (r0000100 = 1732 or r0000100 = 1928 or r0000100 = 2124 or r0000100 = 4439 or r0000100 = 10494) then do;
cath79 = 0;
bapt79 = 0;
end;

**region in 1979;
**will use this for comparison for fullest sample;
reg79 = r0216400;
*region year of birth (or close);
regy = .;
if (cyob = 1979 and r0216400 gt 0) then regy = r0216400; 
if (cyob = 1980 and r0405700 gt 0) then regy = r0405700; 
if (cyob = 1981 and r0602810 gt 0) then regy = r0602810; 
if (cyob = 1982 and r0897910 gt 0) then regy = r0897910; 
if (cyob = 1983 and r1144800 gt 0) then regy = r1144800; 
if (cyob = 1984 and r1520000 gt 0) then regy = r1520000; 
if (cyob = 1985 and r1890700 gt 0) then regy = r1890700; 
if (cyob = 1986 and r2257800 gt 0) then regy = r2257800; 
if (cyob = 1987 and r2445200 gt 0) then regy = r2445200; 
if (cyob = 1988 and r2870800 gt 0) then regy = r2870800; 
if (cyob = 1989 and r3074500 gt 0) then regy = r3074500; 
if (cyob = 1990 and r3401200 gt 0) then regy = r3401200; 
if (cyob = 1991 and r3656600 gt 0) then regy = r3656600; 
if (cyob = 1992 and r4007100 gt 0) then regy = r4007100; 
if (cyob = 1993 and r4418200 gt 0) then regy = r4418200; 
if (cyob = 1994 and r5081200 gt 0) then regy = r5081200; 
if (cyob = 1996 and r5166500 gt 0) then regy = r5166500; 
if (cyob = 1998 and r6479100 gt 0) then regy = r6479100; 
if (cyob = 2000 and r7006800 gt 0) then regy = r7006800; 
if (cyob = 2002 and r7704100 gt 0) then regy = r7704100; 
if (cyob = 2004 and r8496500 gt 0) then regy = r8496500; 
if (cyob = 2006 and T0988300 gt 0) then regy = T0988300; 
if (cyob = 2008 and T2210300 gt 0) then regy = T2210300; 

regyn1 = .;
if (cyob = 1980 and r0216400 gt 0) then regyn1 = r0216400; 
if (cyob = 1981 and r0405700 gt 0) then regyn1 = r0405700; 
if (cyob = 1982 and r0602810 gt 0) then regyn1 = r0602810; 
if (cyob = 1983 and r0897910 gt 0) then regyn1 = r0897910; 
if (cyob = 1984 and r1144800 gt 0) then regyn1 = r1144800; 
if (cyob = 1985 and r1520000 gt 0) then regyn1 = r1520000; 
if (cyob = 1986 and r1890700 gt 0) then regyn1 = r1890700; 
if (cyob = 1987 and r2257800 gt 0) then regyn1 = r2257800; 
if (cyob = 1988 and r2445200 gt 0) then regyn1 = r2445200; 
if (cyob = 1989 and r2870800 gt 0) then regyn1 = r2870800; 
if (cyob = 1990 and r3074500 gt 0) then regyn1 = r3074500; 
if (cyob = 1991 and r3401200 gt 0) then regyn1 = r3401200; 
if (cyob = 1992 and r3656600 gt 0) then regyn1 = r3656600; 
if (cyob = 1993 and r4007100 gt 0) then regyn1 = r4007100; 
if (cyob = 1994 and r4418200 gt 0) then regyn1 = r4418200; 
if (cyob = 1995 and r5081200 gt 0) then regyn1 = r5081200; 
if (cyob = 1997 and r5166500 gt 0) then regyn1 = r5166500; 
if (cyob = 1999 and r6479100 gt 0) then regyn1 = r6479100; 
if (cyob = 2001 and r7006800 gt 0) then regyn1 = r7006800; 
if (cyob = 2003 and r7704100 gt 0) then regyn1 = r7704100; 
if (cyob = 2005 and r8496500 gt 0) then regyn1 = r8496500; 
if (cyob = 2007 and T0988300 gt 0) then regyn1 = r8496500; 

regyp1 = .;
if (cyob = 1978 and r0216400 gt 0) then regyp1 = r0216400; 
if (cyob = 1979 and r0405700 gt 0) then regyp1 = r0405700; 
if (cyob = 1980 and r0602810 gt 0) then regyp1 = r0602810; 
if (cyob = 1981 and r0897910 gt 0) then regyp1 = r0897910; 
if (cyob = 1982 and r1144800 gt 0) then regyp1 = r1144800; 
if (cyob = 1983 and r1520000 gt 0) then regyp1 = r1520000; 
if (cyob = 1984 and r1890700 gt 0) then regyp1 = r1890700; 
if (cyob = 1985 and r2257800 gt 0) then regyp1 = r2257800; 
if (cyob = 1986 and r2445200 gt 0) then regyp1 = r2445200; 
if (cyob = 1987 and r2870800 gt 0) then regyp1 = r2870800; 
if (cyob = 1988 and r3074500 gt 0) then regyp1 = r3074500; 
if (cyob = 1989 and r3401200 gt 0) then regyp1 = r3401200; 
if (cyob = 1990 and r3656600 gt 0) then regyp1 = r3656600; 
if (cyob = 1991 and r4007100 gt 0) then regyp1 = r4007100; 
if (cyob = 1992 and r4418200 gt 0) then regyp1 = r4418200; 
if (cyob = 1993 and r5081200 gt 0) then regyp1 = r5081200; 
if (cyob = 1995 and r5166500 gt 0) then regyp1 = r5166500; 
if (cyob = 1997 and r6479100 gt 0) then regyp1 = r6479100; 
if (cyob = 1999 and r7006800 gt 0) then regyp1 = r7006800; 
if (cyob = 2001 and r7704100 gt 0) then regyp1 = r7704100; 
if (cyob = 2003 and r8496500 gt 0) then regyp1 = r8496500; 
if (cyob = 2005 and T0988300 gt 0) then regyp1 = T0988300;
if (cyob = 2007 and T2210300 gt 0) then regyp1 = T0988300;

**form region measure;
region = .;
if regy ne . then region = regy;
if (region = . and regyp1 ne .) then region = regyp1;
if (region = . and regyn1 ne .) then region = regyn1;

**family income;
**will define at age 5/6 assessment, given every other year interviewing after 1994, etc.;
*note, income is asked relative to the prior calendar year, so inc79 is really for 1978;
*convert to real 1982-1984 $s;
inc79 = r0217900;
if inc79 lt 0 then inc79 = .;
inc79 = inc79*1.532;
inc80 = r0406010;
if inc80 lt 0 then inc80 = .;
inc80 = inc80*1.380;
inc81 = r0618410;
if inc81 lt 0 then inc81 = .;
inc81 = inc81*1.215;
inc82 = r0898600;
if inc82 lt 0 then inc82 = .;
inc82 = inc82*1.098;
inc83 = r1144500;
if inc83 lt 0 then inc83 = .;
inc83 = inc83*1.035;
inc84 = r1519700;
if inc84 lt 0 then inc84 = .;
inc84 = inc84*1.003;
inc85 = r1890400;
if inc85 lt 0 then inc85 = .;
inc85 = inc85*.961;
inc86 = r2257500;
if inc86 lt 0 then inc86 = .;
inc86 = inc86*.928;
inc87 = r2444700;
if inc87 lt 0 then inc87 = .;
inc87 = inc87*.913;
inc88 = r2870200;
if inc88 lt 0 then inc88 = .;
inc88 = inc88*.88;
inc89 = r3074000;
if inc89 lt 0 then inc89 = .;
inc89 = inc89*.846;
inc90 = r3400700;
if inc90 lt 0 then inc90 = .;
inc90 = inc90*.807;
inc91 = r3656100;
if inc91 lt 0 then inc91 = .;
inc91 = inc91*.766;
inc92 = r4006600;
if inc92 lt 0 then inc92 = .;
inc92 = inc92*.734;
inc93 = r4417700;
if inc93 lt 0 then inc93 = .;
inc93 = inc93*.713;
inc94 = r5080700;
if inc94 lt 0 then inc94 = .;
inc94 = inc94*.692;
inc96 = r5166000;
if inc96 lt 0 then inc96 = .;
inc96 = inc96*.656;
inc98 = r6478700;
if inc98 lt 0 then inc98 = .;
inc98 = inc98*.623;
inc00 = r7006500;
if inc00 lt 0 then inc00 = .;
inc00 = inc00*.6;
inc02 = r7703700;
if inc02 lt 0 then inc02 = .;
inc02 = inc02*.565;
inc04 = r8496100;
if inc04 lt 0 then inc04 = .;
inc04 = inc04*.543;
inc06 = t0987800;
if inc06 lt 0 then inc06 = .;
inc06 = inc06*.512;
inc08 = T2210000;
if inc08 lt 0 then inc08 = .;
inc08 = inc08*.482;

*family poverty status, again, based on family income, so really for prior year;
pov79 = r0217910;
if pov79 lt 0 then pov79 = .;
pov80 = r0406100;
if pov80 lt 0 then pov80 = .;
pov81 = r0618500;
if pov81 lt 0 then pov81 = .;
pov82 = r0898700;
if pov82 lt 0 then pov82 = .;
pov83 = r1144600;
if pov83 lt 0 then pov83 = .;
pov84 = r1519800;
if pov84 lt 0 then pov84 = .;
pov85 = r1890500;
if pov85 lt 0 then pov85 = .;
pov86 = r2257600;
if pov86 lt 0 then pov86 = .;
pov87 = r2444900;
if pov87 lt 0 then pov87 = .;
pov88 = r2870400;
if pov88 lt 0 then pov88 = .;
pov89 = r3074100;
if pov89 lt 0 then pov89 = .;
pov90 = r3400800;
if pov90 lt 0 then pov90 = .;
pov91 = r3656200;
if pov91 lt 0 then pov91 = .;
pov92 = r4006700;
if pov92 lt 0 then pov92 = .;
pov93 = r4417800;
if pov93 lt 0 then pov93 = .;
pov94 = r5080800;
if pov94 lt 0 then pov94 = .;
pov96 = r5166100;
if pov96 lt 0 then pov96 = .;
pov98 = r6478800;
if pov98 lt 0 then pov98 = .;
pov00 = r7006600;
if pov00 lt 0 then pov00 = .;
pov02 = r7703900;
if pov02 lt 0 then pov02 = .;
pov04 = r8496300;
if pov04 lt 0 then pov04 = .;
pov06 = t0987900;
if pov06 lt 0 then pov06 = .;
pov08 = T2210100;
if pov08 lt 0 then pov08 = .;

***now highest grade completed;
hgc79 = r0216701;
if hgc79 lt 0 then hgc79 = .;
if hgc79 = 95 then hgc79 = .;
hgc80 = r0406401;
if hgc80 lt 0 then hgc80 = .;
if hgc80 = 95 then hgc80 = .;
hgc81 = r0618901;
if hgc81 lt 0 then hgc81 = .;
if hgc81 = 95 then hgc81 = .;
hgc82 = r0898201;
if hgc82 lt 0 then hgc82 = .;
if hgc82 = 95 then hgc82 = .;
hgc83 = r1145001;
if hgc83 lt 0 then hgc83 = .;
if hgc83 = 95 then hgc83 = .;
hgc84 = r1520201;
if hgc84 lt 0 then hgc84 = .;
if hgc84 = 95 then hgc84 = .;
hgc85 = r1890901;
if hgc85 lt 0 then hgc85 = .;
if hgc85 = 95 then hgc85 = .;
hgc86 = r2258001;
if hgc86 lt 0 then hgc86 = .;
if hgc86 = 95 then hgc86 = .;
hgc87 = r2445401;
if hgc87 lt 0 then hgc87 = .;
if hgc87 = 95 then hgc87 = .;
hgc88 = r2871101;
if hgc88 lt 0 then hgc88 = .;
if hgc88 = 95 then hgc88 = .;
hgc89 = r3074801;
if hgc89 lt 0 then hgc89 = .;
if hgc89 = 95 then hgc89 = .;
hgc90 = r3401501;
if hgc90 lt 0 then hgc90 = .;
if hgc90 = 95 then hgc90 = .;
hgc91 = r3656901;
if hgc91 lt 0 then hgc91 = .;
if hgc91 = 95 then hgc91 = .;
hgc92 = r4007401;
if hgc92 lt 0 then hgc92 = .;
if hgc92 = 95 then hgc92 = .;
hgc93 = r4418501;
if hgc93 lt 0 then hgc93 = .;
if hgc93 = 95 then hgc93 = .;
hgc94 = r5103900;
if hgc94 lt 0 then hgc94 = .;
if hgc94 = 95 then hgc94 = .;
hgc96 = r5166901;
if hgc96 lt 0 then hgc96 = .;
if hgc96 = 95 then hgc96 = .;
hgc98 = r6479600;
if hgc98 lt 0 then hgc98 = .;
if hgc98 = 95 then hgc98 = .;
hgc00 = r7007300;
if hgc00 lt 0 then hgc00 = .;
if hgc00 = 95 then hgc00 = .;
hgc02 = r7704600;
if hgc02 lt 0 then hgc02 = .;
if hgc02 = 95 then hgc02 = .;
hgc04 = r8497000;
if hgc04 lt 0 then hgc04 = .;
if hgc04 = 95 then hgc04 = .;
hgc06 = t0988800;
if hgc06 lt 0 then hgc06 = .;
if hgc06 = 95 then hgc06 = .;
hgc08 = T2210700;
if hgc08 lt 0 then hgc08 = .;
if hgc08 = 95 then hgc08 = .;

*highest grade completed for year of birth;
hgcyob = .;
if cyob gt 0 then do;
if cyob le 1979 then hgcyob = hgc79;
if cyob = 1980 then hgcyob = hgc80;
if cyob = 1981 then hgcyob = hgc81;
if cyob = 1982 then hgcyob = hgc82;
if cyob = 1983 then hgcyob = hgc83;
if cyob = 1984 then hgcyob = hgc84;
if cyob = 1985 then hgcyob = hgc85;
if cyob = 1986 then hgcyob = hgc86;
if cyob = 1987 then hgcyob = hgc87;
if cyob = 1988 then hgcyob = hgc88;
if cyob = 1989 then hgcyob = hgc89;
if cyob = 1990 then hgcyob = hgc90;
if cyob = 1991 then hgcyob = hgc91;
if cyob = 1992 then hgcyob = hgc92;
if cyob = 1993 then hgcyob = hgc93;
if cyob = 1994 then hgcyob = hgc94;
if cyob = 1995 then hgcyob = hgc96;
if cyob = 1996 then hgcyob = hgc96;
if cyob = 1997 then hgcyob = hgc98;
if cyob = 1998 then hgcyob = hgc98;
if cyob = 1999 then hgcyob = hgc00;
if cyob = 2000 then hgcyob = hgc00;
if cyob = 2001 then hgcyob = hgc02;
if cyob = 2002 then hgcyob = hgc02;
if cyob = 2003 then hgcyob = hgc04;
if cyob = 2004 then hgcyob = hgc04;
if cyob = 2005 then hgcyob = hgc06;
if cyob = 2006 then hgcyob = hgc06;
if cyob = 2007 then hgcyob = hgc08;
if cyob = 2008 then hgcyob = hgc08;
*just bump up a year to fill in if possible;
if hgcyob = . then do;
if cyob le 1979 then hgcyob = hgc80;
if cyob = 1980 then hgcyob = hgc81;
if cyob = 1981 then hgcyob = hgc82;
if cyob = 1982 then hgcyob = hgc83;
if cyob = 1983 then hgcyob = hgc84;
if cyob = 1984 then hgcyob = hgc85;
if cyob = 1985 then hgcyob = hgc86;
if cyob = 1986 then hgcyob = hgc87;
if cyob = 1987 then hgcyob = hgc88;
if cyob = 1988 then hgcyob = hgc89;
if cyob = 1989 then hgcyob = hgc90;
if cyob = 1990 then hgcyob = hgc91;
if cyob = 1991 then hgcyob = hgc92;
if cyob = 1992 then hgcyob = hgc93;
if cyob = 1993 then hgcyob = hgc94;
end;
*just bump down a year to fill in if possible;
if hgcyob = . then do;
if cyob = 1980 then hgcyob = hgc79;
if cyob = 1981 then hgcyob = hgc80;
if cyob = 1982 then hgcyob = hgc81;
if cyob = 1983 then hgcyob = hgc82;
if cyob = 1984 then hgcyob = hgc83;
if cyob = 1985 then hgcyob = hgc84;
if cyob = 1986 then hgcyob = hgc85;
if cyob = 1987 then hgcyob = hgc86;
if cyob = 1988 then hgcyob = hgc87;
if cyob = 1989 then hgcyob = hgc88;
if cyob = 1990 then hgcyob = hgc89;
if cyob = 1991 then hgcyob = hgc90;
if cyob = 1992 then hgcyob = hgc91;
if cyob = 1993 then hgcyob = hgc92;
if cyob = 1994 then hgcyob = hgc93;
end;
**now try to bump up two years...;
if hgcyob = . then do;
if cyob le 1979 then hgcyob = hgc81;
if cyob = 1980 then hgcyob = hgc82;
if cyob = 1981 then hgcyob = hgc83;
if cyob = 1982 then hgcyob = hgc84;
if cyob = 1983 then hgcyob = hgc85;
if cyob = 1984 then hgcyob = hgc86;
if cyob = 1985 then hgcyob = hgc87;
if cyob = 1986 then hgcyob = hgc88;
if cyob = 1987 then hgcyob = hgc89;
if cyob = 1988 then hgcyob = hgc90;
if cyob = 1989 then hgcyob = hgc91;
if cyob = 1990 then hgcyob = hgc92;
if cyob = 1991 then hgcyob = hgc93;
if cyob = 1992 then hgcyob = hgc94;
if cyob = 1994 then hgcyob = hgc96;
if cyob = 1996 then hgcyob = hgc98;
if cyob = 1998 then hgcyob = hgc00;
if cyob = 2000 then hgcyob = hgc02;
if cyob = 2002 then hgcyob = hgc04;
if cyob = 2004 then hgcyob = hgc06;
if cyob = 2006 then hgcyob = hgc08;
end;
*just try to bump down two years to fill in if possible;
if hgcyob = . then do;
if cyob = 1981 then hgcyob = hgc79;
if cyob = 1982 then hgcyob = hgc80;
if cyob = 1983 then hgcyob = hgc81;
if cyob = 1984 then hgcyob = hgc82;
if cyob = 1985 then hgcyob = hgc83;
if cyob = 1986 then hgcyob = hgc84;
if cyob = 1987 then hgcyob = hgc85;
if cyob = 1988 then hgcyob = hgc86;
if cyob = 1989 then hgcyob = hgc87;
if cyob = 1990 then hgcyob = hgc88;
if cyob = 1991 then hgcyob = hgc89;
if cyob = 1992 then hgcyob = hgc90;
if cyob = 1993 then hgcyob = hgc91;
if cyob = 1994 then hgcyob = hgc92;
if cyob = 1995 then hgcyob = hgc93;
if cyob = 1996 then hgcyob = hgc94;
if cyob = 1997 then hgcyob = hgc96;
if cyob = 1998 then hgcyob = hgc96;
if cyob = 1999 then hgcyob = hgc98;
if cyob = 2000 then hgcyob = hgc98;
if cyob = 2001 then hgcyob = hgc00;
if cyob = 2002 then hgcyob = hgc00;
if cyob = 2003 then hgcyob = hgc02;
if cyob = 2004 then hgcyob = hgc02;
if cyob = 2005 then hgcyob = hgc04;
if cyob = 2006 then hgcyob = hgc04;
if cyob = 2008 then hgcyob = hgc06;
end;
end;

*fill in a few by hand;
if hgcyob = . then do;
if (c0000100 = 38901 or c0000100 = 38902 or c0000100 = 205202
   or c0000100 = 685601 or c0000100 = 828406 or c0000100 = 914301) then hgcyob = hgc79;
if (c0000100 = 55202 or c0000100 = 86902 or c0000100 = 169901
  or c0000100 = 172202 or c0000100 = 757402 or c0000100 = 799001
  or c0000100 = 1197501) then hgcyob = hgc84;
if (c0000100 = 84503) then hgcyob = hgc82;
if (c0000100 = 142102 or c0000100 = 1218501 or c0000100 = 147802
   or c0000100 = 620402 or c0000100 = 1048502) then hgcyob = hgc83;
if (c0000100 = 181502 or c0000100 = 545901) then hgcyob = hgc92;
if (c0000100 = 394001 or c0000100 = 559302 or c0000100 = 559303
  or c0000100 = 1198801 or c0000100 = 1198802) then hgcyob = hgc80;
if (c0000100 = 615001 or c0000100 = 724701 or c0000100 = 934401
   or c0000100 = 934402 or c0000100 = 965502) then hgcyob = hgc88;
if (c0000100 = 1201 or c0000100 = 111001 or c0000100 = 398302 or c0000100 = 408001
   or c0000100 = 427202 or c0000100 = 455401 or c0000100 = 474403 or c0000100 = 476802
   or c0000100 = 476803 or c0000100 = 476804 or c0000100 = 524002 or c0000100 = 620501
   or c0000100 = 620502 or c0000100 = 678803 or c0000100 = 976302 or c0000100 = 1003402
   or c0000100 = 1003403 or c0000100 = 1013002 or c0000100 = 1052104 or c0000100 = 1052105
   or c0000100 = 334501) then hgcyob = hgc85;
if (c0000100 = 86901 or c0000100 = 108601 or c0000100 = 350501 or c0000100 = 368803
 or c0000100 = 368804 or c0000100 = 458401 or c0000100 = 545201 or c0000100 = 547201
 or c0000100 = 696202) then hgcyob = hgc98;
if (c0000100 = 192202 or c0000100 = 193201 or c0000100 = 835103
    or c0000100 = 515301 or c0000100 = 621402) then hgcyob = hgc94;
if (c0000100 = 228001) then hgcyob = hgc92;
if (c0000100 = 675302 or c0000100 = 936602) then hgcyob = hgc88;
if (c0000100 = 944001 or c0000100 = 944002 or c0000100 = 1217603) then hgcyob = hgc00;
if  (c0000100 = 1040603) then hgcyob = hgc93;
if (c0000100 = 112102 or c0000100 = 806603) then hgcyob = hgc87;
if (c0000100 = 868001 or c0000100 = 868002) then hgcyob = hgc86;
if (c0000100 = 369102) then hgcyob = hgc92;
if (c0000100 = 68903 or c0000100 = 319006 or c0000100 = 605802
   or c0000100 = 851104) then hgcyob = hgc98;
end;

**now do pov and inc for year56, assessment year;
inc56 = .;
pov56 = .;
if year56 = 1986 then inc56 = inc86;
if year56 = 1986 then pov56 = pov86;
if year56 = 1988 then inc56 = inc88;
if year56 = 1988 then pov56 = pov88;
if year56 = 1990 then inc56 = inc90;
if year56 = 1990 then pov56 = pov90;
if year56 = 1992 then inc56 = inc92;
if year56 = 1992 then pov56 = pov92;
if year56 = 1994 then inc56 = inc94;
if year56 = 1994 then pov56 = pov94;
if year56 = 1996 then inc56 = inc96;
if year56 = 1996 then pov56 = pov96;
if year56 = 1998 then inc56 = inc98;
if year56 = 1998 then pov56 = pov98;
if year56 = 2000 then inc56 = inc00;
if year56 = 2000 then pov56 = pov00;
if year56 = 2002 then inc56 = inc02;
if year56 = 2002 then pov56 = pov02;
if year56 = 2004 then inc56 = inc04;
if year56 = 2004 then pov56 = pov04;
if year56 = 2006 then inc56 = inc06;
if year56 = 2006 then pov56 = pov06;
if year56 = 2008 then inc56 = inc08;
if year56 = 2008 then pov56 = pov08;

proc means;
run;
